package com.veetao.api.controller;

import com.veetao.api.annotation.McpMethod;
import com.veetao.api.dao.SysConfigDAO;
import com.veetao.api.model.ApiFacadeAdapter;
import com.veetao.api.model.CommandContext;
import com.veetao.api.resp.SingleDataResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author liupeng
 * @Date 2018/5/4 11:10
 */
@Component
public class SystemController extends ApiFacadeAdapter {
    @Autowired
    private SysConfigDAO dao;

    @McpMethod(name="system.status.isActive", ver="1.0", desc="檢查接口狀態", logon=false)
    public SingleDataResp isActive(CommandContext context) {
        Map<String, Object> result = new HashMap<>();
        int s=dao.getMysqlInstanceReturn();
        boolean databaseStatus=false;
        if (s > 0) {
            databaseStatus=true;
        }
        result.put("databaseStatus", databaseStatus);
        return new SingleDataResp(result);
    }
}
